package com.qf.service.impl;

import com.qf.model.entity.Healthencyclopedia;
import com.qf.dao.HealthencyclopediaDao;
import com.qf.service.HealthencyclopediaService;
import com.qf.util.R;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.Map;

/**
 * (Healthencyclopedia)表服务实现类
 *
 * @author ZhiHuiJun
 * @since 2024-05-03 18:36:32
 */
@Service("healthencyclopediaService")
public class HealthencyclopediaServiceImpl implements HealthencyclopediaService {
    @Autowired
    private HealthencyclopediaDao healthencyclopediaDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Healthencyclopedia queryById(Integer id) {
        return this.healthencyclopediaDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @return 查询结果
     */
    @Override
    public List<Healthencyclopedia> queryByPage(Integer pageNum) {
        return this.healthencyclopediaDao.queryAllByLimit();
    }

    /**
     * 新增数据
     *
     * @param healthencyclopedia 实例对象
     * @return 实例对象
     */
    @Override
    public boolean insert(Healthencyclopedia healthencyclopedia) {
       int i = healthencyclopediaDao.insert(healthencyclopedia);
       if (i>0){
           return true;
       }
       return false;
    }

    /**
     * 修改数据
     *
     * @param healthencyclopedia 实例对象
     * @return 实例对象
     */
    @Override
    public boolean update(Healthencyclopedia healthencyclopedia) {
       int i = healthencyclopediaDao.update(healthencyclopedia);
       if (i>0){
           return true;
       }
       return false;
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.healthencyclopediaDao.deleteById(id) > 0;
    }

    @Override
    public List<Healthencyclopedia> selectHealthyByCondition(Map<String, Object> map) {
        return healthencyclopediaDao.selectHealthyByCondition(map);
    }

    @Override
    public int delBatch(List<Integer> list) {
        int i = healthencyclopediaDao.delBatch(list);
        if (i>0){
            return 1;
        }
        return -1;
    }
}
